<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKfUsers extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('username', 20)->comment("用户名");
            $table->char('mobile', 20)->comment("手机号");
            $table->string('password', 100)->comment("密码");
            $table->string('salt', 10)->comment("用户盐");
            $table->unsignedTinyInteger('status')->default(0)->comment("用户状态 0 正常 1 禁用 3：其他");
            $table->unsignedTinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除 1：已删除");
            $table->integer('createdAt');
            $table->integer('updatedAt');

            // 创建索引
            $table->unique('mobile');
            $table->unique('username');
            $table->collation = 'utf8mb4_general_ci';
        });

        $prefix = config('other.DB_PREFIX','');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}users` COMMENT = '用户表'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
